vulkancontext: Assume the window geometry when extents are bogus
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Tue, 3 Jan 2017 23:11:57 +0000 (21:11 -0200)
committerBenjamin Otte <otte@redhat.com>
Wed, 4 Jan 2017 12:23:48 +0000 (13:23 +0100)
When the current extent is -1, we should assume whatever size
the GdkWindow has.

gdk/gdkvulkancontext.c

index e64cd2f1eb44b002bb0dd7fe5ab69d77e9b1b2d0..a6b17326194eaabdda22be33d7bc0a4c0df81057 100644 (file)
@@ -216,6 +216,17 @@ gdk_vulkan_context_check_swapchain (GdkVulkanContext  *context,
       composite_alpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
     }
 
+  /*
+   * Per https://www.khronos.org/registry/vulkan/specs/1.0-wsi_extensions/xhtml/vkspec.html#VkSurfaceCapabilitiesKHR
+   * the current extent may assume a special value, meaning that the extend should assume whatever
+   * value the window has.
+   */
+  if (capabilities.currentExtent.width == -1 || capabilities.currentExtent.height == -1)
+    {
+      capabilities.currentExtent.width = gdk_window_get_width (window) * gdk_window_get_scale_factor (window);
+      capabilities.currentExtent.height = gdk_window_get_height (window) * gdk_window_get_scale_factor (window);
+    }
+
   res = GDK_VK_CHECK (vkCreateSwapchainKHR, device,
                                             &(VkSwapchainCreateInfoKHR) {
                                                 .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,